home *** CD-ROM | disk | FTP | other *** search
- // Copyright (C) 1997-2002 Alias|Wavefront,
- // a division of Silicon Graphics Limited.
- //
- // The information in this file is provided for the exclusive use of the
- // licensees of Alias|Wavefront. Such users have the right to use, modify,
- // and incorporate this code into other products for purposes authorized
- // by the Alias|Wavefront license agreement, without fee.
- //
- // ALIAS|WAVEFRONT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- // INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
- // EVENT SHALL ALIAS|WAVEFRONT BE LIABLE FOR ANY SPECIAL, INDIRECT OR
- // CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
- // DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
- // TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
- // PERFORMANCE OF THIS SOFTWARE.
- //
- // Copyright (C) 1997-2002 Alias|Wavefront,
- // a division of Silicon Graphics Limited.
- //
- // The information in this file is provided for the exclusive use of the
- // licensees of Alias|Wavefront. Such users have the right to use, modify,
- // and incorporate this code into other products for purposes authorized
- // by the Alias|Wavefront license agreement, without fee.
- //
- // ALIAS|WAVEFRONT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- // INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
- // EVENT SHALL ALIAS|WAVEFRONT BE LIABLE FOR ANY SPECIAL, INDIRECT OR
- // CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
- // DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
- // TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
- // PERFORMANCE OF THIS SOFTWARE.
- //
- // Alias|Wavefront Script File
- // MODIFY THIS AT YOUR OWN RISK
- //
- // adapted from cpam's polyGridUVWin.mel
- //
- // creates UI for polyGridUV.mel command
-
- //
- // Procedure Name:
- // setOptionVars
- //
- // Description:
- // Initialize the option values.
- //
- // Input Arguments:
- // Whether to set the options to default values.
- //
- // Return Value:
- // None.
- //
- proc setOptionVars(int $forceFactorySettings)
- {
- // U
- //
- if ($forceFactorySettings || !`optionVar -exists polyGridUVValueU`) {
- optionVar -intValue polyGridUVValueU 256;
- }
-
- // V
- //
- if ($forceFactorySettings || !`optionVar -exists polyGridUVValueV`) {
- optionVar -intValue polyGridUVValueV 256;
- }
-
- // Pixel
- //
- if ($forceFactorySettings || !`optionVar -exists polyGridUVValuePixel`) {
- optionVar -intValue polyGridUVValuePixel 1;
- }
- }
-
- //
- // Procedure Name:
- // polyGridUVSetup
- //
- // Description:
- // Update the state of the option box UI to reflect the option values.
- //
- // Input Arguments:
- // parent - Top level parent layout of the option box UI.
- // Required so that UI object names can be
- // successfully resolved.
- //
- // forceFactorySettings - Whether the option values should be set to
- // default values.
- //
- // Return Value:
- // None.
- //
- global proc polyGridUVSetup(string $parent, int $forceFactorySettings)
- {
- // Retrieve the option settings
- //
- setOptionVars($forceFactorySettings);
-
- setParent $parent;
-
- // Query the optionVar's and set the values into the controls.
-
- // U
- //
- intSliderGrp -edit
- -value `optionVar -query polyGridUVValueU`
- ugrid;
-
- // V
- //
- intSliderGrp -edit
- -value `optionVar -query polyGridUVValueV`
- vgrid;
-
- // Pixel
- //
- radioButtonGrp -edit
- -select `optionVar -query polyGridUVValuePixel`
- snap;
- }
-
-
- //
- // Procedure Name:
- // polyGridUVCallback
- //
- // Description:
- // Update the option values with the current state of the option box UI.
- //
- // Input Arguments:
- // parent - Top level parent layout of the option box UI. Required so
- // that UI object names can be successfully resolved.
- //
- // doIt - Whether the command should execute.
- //
- // Return Value:
- // None.
- //
- global proc polyGridUVCallback(string $parent, int $doIt)
- {
- setParent $parent;
-
- // Set the optionVar's from the control values, and then
- // perform the command.
-
- // U
- //
- optionVar -intValue polyGridUVValueU
- `intSliderGrp -query -value ugrid`;
-
- // V
- //
- optionVar -intValue polyGridUVValueV
- `intSliderGrp -query -value vgrid`;
-
- // Pixel
- //
- optionVar -intValue polyGridUVValuePixel
- (`radioButtonGrp -query -select snap` - 1);
-
-
- if ($doIt) {
- performPolyGridUV 0;
- addToRecentCommandQueue "performPolyGridUV 0" "PolyGridUV";
- }
- }
-
- //
- // Procedure Name:
- // changePreset
- //
- // Description:
- // Helper procedure which sets the slider values to match the
- // item selected from the mapSizePreset menu group.
- //
- // Input Arguments:
- // None.
- //
- // Return Value:
- // None.
- //
- global proc performPolyGridUV_changePreset(){
- int $presets[] = {0, 0, 1024, 512, 256, 128, 64, 32, 16};
- int $selectedItem = `optionMenuGrp -query -select mapSizePreset`;
- intSliderGrp -edit -value $presets[$selectedItem] ugrid;
- intSliderGrp -edit -value $presets[$selectedItem] vgrid;
-
- }
-
-
- //
- // Procedure Name:
- // polyGridUVOptions
- //
- // Description:
- // Construct the option box UI. Involves accessing the standard option
- // box and customizing the UI accordingly.
- //
- // Input Arguments:
- // None.
- //
- // Return Value:
- // None.
- //
- proc polyGridUVOptions()
- {
- // Name of the command for this option box.
- //
- string $commandName = "polyGridUV";
-
- // Build the option box actions.
- //
- string $callback = ($commandName + "Callback");
- string $setup = ($commandName + "Setup");
-
- // Get the option box.
- //
- string $layout = getOptionBox();
- setParent $layout;
-
- // Pass the command name to the option box.
- //
- setOptionBoxCommandName($commandName);
-
- // Activate the default UI template.
- //
- setUITemplate -pushTemplate DefaultTemplate;
-
- // Turn on the wait cursor.
- //
- waitCursor -state 1;
-
- tabLayout -scr true -tv false;
- string $parent = `columnLayout -adjustableColumn 1`;
-
- optionMenuGrp -l "Map Size Presets"
- -cc "performPolyGridUV_changePreset"
- mapSizePreset;
-
- menuItem -l " Custom/Non Square";
- menuItem -l "1024 Map";
- menuItem -l " 512 Map";
- menuItem -l " 256 Map";
- menuItem -l " 128 Map";
- menuItem -l " 64 Map";
- menuItem -l " 32 Map";
- menuItem -l " 16 Map";
-
- intSliderGrp
- -label "Grid U"
- -min 1
- -max 1024
- -f 1
- -fmn 1
- -fmx 1024
- -cc "optionMenuGrp -edit -select 1 mapSizePreset;"
- ugrid;
-
- intSliderGrp
- -label "Grid V"
- -min 1
- -max 1024
- -f 1
- -fmn 1
- -fmx 1024
- -cc "optionMenuGrp -edit -select 1 mapSizePreset;"
- vgrid;
-
- radioButtonGrp -numberOfRadioButtons 2
- -label "Move UVs to" -labelArray2 "Pixel Border" "Pixel Center"
- snap;
-
- // Turn off the wait cursor.
- //
- waitCursor -state 0;
-
- // Deactivate the default UI template.
- //
- setUITemplate -popTemplate;
-
- // 'Apply' button.
- //
- string $applyBtn = getOptionBoxApplyBtn();
- button -edit
- -label "Apply and Close"
- -command ($callback + " " + $parent + " " + 1)
- $applyBtn;
-
- // 'Save' button.
- //
- string $saveBtn = getOptionBoxSaveBtn();
- button -edit
- -command ($callback + " " + $parent + " " + 0 + "; hideOptionBox")
- $saveBtn;
-
- // 'Reset' button.
- //
- string $resetBtn = getOptionBoxResetBtn();
- button -edit
- -command ($setup + " " + $parent + " " + 1)
- $resetBtn;
-
- // Set the option box title.
- //
- setOptionBoxTitle("Poly Grid UV Options");
-
- // Customize the 'Help' menu item text.
- //
- setOptionBoxHelpTag( "PolyGridUV" );
-
- // Set the current values of the option box.
- //
- eval (($setup + " " + $parent + " " + 0));
-
- // Show the option box.
- //
- showOptionBox();
- }
-
- //
- // Procedure Name:
- // polyGridUVHelp
- //
- // Description:
- // Return a short description about this command.
- //
- // Input Arguments:
- // None.
- //
- // Return Value:
- // string.
- //
- proc string polyGridUVHelp()
- {
- return
- " Command: polyGridUV - snap selected UVs to user specified grid.\n" +
- "Selection: UVs.";
- }
-
- //
- // Procedure Name:
- // assembleCmd
- //
- // Description:
- // Construct the command that will apply the option box values.
- //
- // Input Arguments:
- // None.
- //
- // Return Value:
- // string.
- //
- proc string assembleCmd()
- {
- setOptionVars(false);
-
- string $cmd = "polyGridUV" + " " +
- `optionVar -query polyGridUVValueU` + " " +
- `optionVar -query polyGridUVValueV` + " " +
- `optionVar -query polyGridUVValuePixel`;
-
- return $cmd;
- }
-
- //
- // Procedure Name:
- // performPolyGridUV
- //
- // Description:
- // Perform the polyGridUV command using the corresponding
- // option values. This procedure will also show the option box
- // window if necessary as well as construct the command string
- // that will invoke the polyGridUV command with the current
- // option box values.
- //
- // Input Arguments:
- // 0 - Execute the command.
- // 1 - Show the option box dialog.
- // 2 - Return the command.
- //
- // Return Value:
- // string.
- //
- global proc string performPolyGridUV(int $action)
- {
- string $cmd = "";
-
- switch ($action) {
-
- // Execute the command.
- //
- case 0:
- // Retrieve the option settings
- //
- setOptionVars(false);
-
- // Get the command.
- //
- $cmd = `assembleCmd`;
-
- // Execute the command with the option settings.
- //
- evalEcho($cmd);
-
- break;
-
- // Show the option box.
- //
- case 1:
- polyGridUVOptions;
- break;
-
- // Return the command string.
- //
- case 2:
- // Retrieve the option settings.
- //
- setOptionVars (false);
-
- // Get the command.
- //
- $cmd = `assembleCmd`;
- break;
- }
- return $cmd;
- }
-